from random import choices
from re import template
from django.db import models
from blueapps.account.models import User

# Create your models here.

class ListStatus(models.Model):
  PENDING = 0 # 待完成
  COMPLETED = 1 # 已完成
  REFUSED = 2 # 已拒绝

# class VisibleRange(models.Model):
#   PRIVATE = 0 # 仅自己可见
#   PUBLIC = 1 # 所有人可见

class List(models.Model):

  status = [
    (ListStatus.PENDING, "待完成"),
    (ListStatus.COMPLETED, "已完成"),
    (ListStatus.REFUSED, "已拒绝")
  ]

  list_title = models.CharField(verbose_name = "任务名称", max_length=50)
  list_content = models.CharField(verbose_name = "任务内容", max_length=100)
  list_status = models.IntegerField(verbose_name="任务状态", choices=status, default=ListStatus.PENDING)
  list_note = models.CharField(verbose_name = "任务备注", max_length=100)
  plan_completion_time = models.DateTimeField('计划完成时间', blank=True, null=True)
  actual_completion_time = models.DateTimeField('实际完成时间', blank = True, null = True)
  create_time = models.DateTimeField('创建时间', auto_now_add=True)


class Template(models.Model):
  visibleRange = [
    (0, "仅自己可见"),
    (1, "所有人可见")
  ]
  template_title = models.CharField(verbose_name = "模板名称", max_length=50)
  template_content = models.CharField(verbose_name = "模板内容", max_length=100)
  template_note = models.CharField(verbose_name="模板备注", max_length=100)
  visible_range = models.IntegerField(verbose_name="可见范围", choices = visibleRange)
  template_update_time = models.DateTimeField(verbose_name="更新时间", auto_now=True)
  template_create_time = models.DateTimeField(verbose_name="创建时间", auto_now_add=True)
  template_create_person = models.CharField(verbose_name="创建人", max_length=50)

  if visible_range == 'PRIVATE':
    def __str__(self):
      return self.template_title